package com.rico.beans;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

@Component("factoryBeanTest")
public class FactoryBeanTest implements FactoryBean<User> {


    //创建的具体bean对象的类型
    @Override
    public Class<?> getObjectType() {
        return User.class;
    }


    //是否单例
    @Override
    public boolean isSingleton() {
        return true;
    }

    //工厂bean 具体创建具体对象是由此getObject()方法来返回的
    @Override
    public User getObject() throws Exception {
        User user= new User();
        user.setUserName("manfred");
        return user;
    }
}